
#ifndef SCHEDULER_H_
#define SCHEDULER_H_

#include <vector>
#include <queue>
#include "Node.h"
#include "OSScheduler.h"
#include "TT.h"
using namespace std;
class Mailer;
class Scheduler : public OSScheduler{
public:
	Scheduler(int algo, vector<Node*> nodes, int quanta, Mailer* mailer);
	virtual ~Scheduler();

	bool Schedule();
	void PrintTT();
	void IncTT(Node* n);
	void UpdateNewReadyQ(queue<Node*> nq);

private:
	vector<Node*> _nodes;
//	pthread_t _currentThread;
	Node* _currentNode;
	int _currentNodeIndex;
	int _quanta;
	TT* _tt;
	int _algo;
	queue<Node*> _readyQ;
	void ContextSwitch(Node*);// changes to next Node in turn
	void RoundRobin();
	void RRInit();
	bool Finished(Node* n);
	Mailer* _mailer;
	bool isStable();
	void printQueue();
	void ResetTTCount(Node* n);
};

#endif /* SCHEDULER_H_ */
